<template>
  <div style="display: flex;justify-content: center;align-items: center;width: 100vw;height: 100vh">
    <img :src="url" alt="二维码不存在">
  </div>
</template>

<script>
import { getQrTime } from "@/api/common";
export default {
  name: 'PageQr',
  data() {
    return {
      rTime: 30000,
      baseUrl: 'http://localhost:9082/qr/createQr',
      url: 'http://localhost:9082/qr/createQr?data=lqc',
      cg: 'lqc'
    }
  },
  created() {
    this.getRefreshTime();
    const { params, query } = this.$route
    if(query.cg){
      this.cg = query.cg
    }
  },
  methods: {
    getRefreshTime(){
      const _this = this
      getQrTime().then(response => {
        _this.rTime = response.data;
        if(!_this.rTime){
          _this.rTime = 30000
        }
        let timer = setInterval(()=>{
          _this.url = _this.baseUrl + '?data='+_this.cg+'&v='+new Date()
        },Number(_this.rTime))
      });
    },

  }
}
</script>


